package com.solution.admin.order.task;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.solution.admin.order.service.OrderService;
import com.solution.admin.settings.entity.KeyMapEntity;
import com.solution.admin.settings.service.KeyMapService;

/**
 * 订单自动签收 功能
 * @author zhaiugo
 */
public class OrderAutoSignTask {

	@Autowired
	private OrderService orderService;
	
	@Autowired
	private KeyMapService keyMapService;

	/**
	 * 定时执行自动签收逻辑
	 */
	public void execute(){
		
		// 查询自动签收天数（发货后多少天未签收，系统自动签收 ）
		List<KeyMapEntity> autoSignList = keyMapService.listKeyMap("autoSignDays");
		int autoSignDays = 999; 
		if(autoSignList != null && autoSignList.size() > 0){
			KeyMapEntity autoSign = autoSignList.get(0);
			autoSignDays = Integer.parseInt(autoSign.getKeyValue());
		}
		// 查询未签收的订单，进行逐个签收
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("autoSignDays", autoSignDays);
		orderService.autoSign(param);
	}
}
